#!usr/bin/python
# -*- coding: UTF-8 -*-
dic1 = {}
a = dic1.fromkeys((1, 2, 3))
print(a)

b = dic1.fromkeys((1, 2, 3), ('one', 'two', 'three'))
print(b)

b = dic1.fromkeys((1, 3), ('数字')) #重新创建字典
print(b)

b = dic1.fromkeys(range(32), '赞') #重新创建字典
print(b)

for eachKey in b.keys():
    print('eachKey', eachKey)


for eachVal in b.values():
    print('eachVal', eachVal)

c = b.get(32)
print('c', dic1)

c = b.get(31)
print('c', c)

c = b.get(3)
print('c', c)

dic1 = {}
a = {'姓名': '小楼'}
b = a
print(b)
a = {} #清空字典， b还存在
print(a)
print(b)

a.clear()
print('a',a)
print('b',b) #还是没清空b，有毛病

a = {1: 'one', 2: 'two', 3: 'three'}
b = a.copy()
c = a
print('a', a)
print('b', b)
print('c', c)

c[4] = 'four'
print('a', a)
print('b', b)
print('c', c)

'''
['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']

'''
#c = dir(dic1)
#print(c)
print('a.pop(2)', a.pop(2)) #
print(a)

print('a.popitem()', a.popitem()) #随机从数组里弹出一个数据
print(a)

setdefault = a.setdefault('小白')
print('setdefault', setdefault)

setdefault = a.setdefault(5, 'five')
print(setdefault)
print(a)
print(c)

print('b', b)
print('a', a)
print('c', c)

b = {'小白': '狗'}
n = a.update(b)
print('updateb', b)
print('a', a)
print('c', c)


